import SwiftyJSON
import BXModel
{% for comment in comments %}
    {{ comment }}
{% endfor %}
{% set m = model %}
{{ m.access_level_modifier }}  struct {{ m.class_name }} :BXModel{
{% for field in fields %}
  {{ m.access_level_modifier }}  {{ field.declare_stmt }}
{% endfor %}

{{ m.access_level_modifier }}  init(json:JSON){
{% for field in fields %}
    {{ field.init_stmt }}
{% endfor %}
}

{{ m.access_level_modifier }}  func toDict() -> [String:Any]{
var dict : [String:Any] = [ : ]
{% for field in fields %}
    {{ field.to_dict_stmt }}
{% endfor %}
return dict
}
}

{% if m.impl_eq %}
    extension {{ m.class_name }}: Equatable{
        {{ m.access_level_modifier }} static func ==(lhs:{{ m.class_name }},rhs:{{ m.class_name }}) -> Bool{
        return lhs.{{m.identifier_field_name  }} == rhs.{{ m.identifier_field_name }}
        }
    }


{% endif %}

{% if m.impl_hash %}
    extension  {{ m.class_name }} : Hashable{
    {{ m.access_level_modifier }}  var hashValue:Int{ return {{ m.identifier_field_name}}.hashValue   }
    }
{% endif %}

{% if m.impl_tos %}
    extension {{ m.class_name }} : CustomStringConvertible{
    {{ m.access_level_modifier }}  var description:String {  return {{ m.guess_tos_field_name() }} }
    }
{% endif %}